<?php

namespace App\Admin\Forms;

use Encore\Admin\Widgets\Form;
use Illuminate\Http\Request;

use App\Models\Config;

class PointsConfig extends Form
{
    public $title = '积分配置';

    public function handle(Request $request)
    {
        Config::where('flag', 'points_num_config')->update(['value->g' => $request->num]);

        admin_toastr('设置成功', 'success');

        return back();
    }

    public function form()
    {
        $this->number('num', '获取积分数量')->min(0)->rules('required');
    }

    public function data()
    {
        return [
            'num'   => Config::pointsNum(),
        ];
    }
}
